#include "icondelegate.h"
#include "ui_icondelegate.h"

#include <QPaintEngine>

IconDelegate::IconDelegate(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::IconDelegate)
{
    ui->setupUi(this);
    ui->icon->setMovie(&m_movie);
}

IconDelegate::~IconDelegate()
{
    delete ui;
}

QString IconDelegate::file() const
{
    return m_file;
}

void IconDelegate::setFile(QString newFile)
{
    m_file = newFile;
    m_movie.setFileName(m_file);
}

void IconDelegate::setDevice(QPaintDevice *newDevice)
{
    m_device = newDevice;
    QPaintEngine *engine = paintEngine();
    engine->setPaintDevice(m_device);
}

void IconDelegate::repaint()
{
    update();
}
